package com.eastfair.certificate.controller;

import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.eastfair.annotation.annotation.base.BaseControllerInfo;
import com.eastfair.annotation.annotation.log.SysLog;
import com.eastfair.annotation.annotation.security.PreAuth;
import com.eastfair.annotation.annotation.tenant.TenantAuth;
import com.eastfair.auth.api.UserAccountServiceFeign;
import com.eastfair.auth.vo.UserAccountVo;
import com.eastfair.certificate.dto.*;
import com.eastfair.certificate.entity.Blacklist;
import com.eastfair.certificate.entity.Certificate;
import com.eastfair.certificate.entity.CertificateOrder;
import com.eastfair.certificate.entity.CertificateUser;
import com.eastfair.certificate.enumeration.*;
import com.eastfair.certificate.exceptioncode.CertificateExceptionCode;
import com.eastfair.certificate.service.*;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;

import com.eastfair.boot.controller.SuperController;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eastfair.certificate.util.ConvertByFormField;
import com.eastfair.certificate.vo.CertificateOrderVO;
import com.eastfair.certificate.vo.CertificateUserVO;
import com.eastfair.certificate.vo.CertificateVO;
import com.eastfair.certificate.vo.FormFieldSubsystemVO;
import com.eastfair.constant.BusinessConstant;
import com.eastfair.core.exception.BizException;
import com.eastfair.core.exception.NoBackBizException;
import com.eastfair.core.utils.ConvertUtil;
import com.eastfair.database.mybatis.typehandler.TypeHandlerUtil;
import com.eastfair.demand.certificate.CertificateUserGroup;
import com.eastfair.echo.core.EchoService;
import com.eastfair.core.base.R;
import com.eastfair.projectcore.enumeration.DataIsolationSystemSceneEnum;
import com.eastfair.venuebooking.api.ExhibitionManageFeign;
import com.eastfair.venuebooking.api.ServiceProviderFeign;
import com.eastfair.venuebooking.vo.ExhibitionSpaceVO;
import com.eastfair.venueservice.dto.ExhibitionManageQuery;
import com.eastfair.venueservice.dto.ServiceProviderDTO;
import com.eastfair.venueservice.vo.ExhibitionManageVO;
import com.eastfair.venueservice.vo.ServiceProviderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.eastfair.boot.request.PageParams;
import com.eastfair.core.context.ContextUtil;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.Size;


/**
 * <p>
 * 前端控制器
 * 用户填写的制证信息
 * </p>
 *
 * @author ligang
 * @date 2022-07-21
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/certificateUser")
@Api(value = "CertificateUser", tags = "用户填写的制证信息")
@PreAuth(replace = "certificate:certificateUser:")
public class CertificateUserController extends SuperController<CertificateUserService, Long, CertificateUser, CertificateUserPageQuery, CertificateUserSaveDTO, CertificateUserUpdateDTO> {

    @Autowired
    private EchoService echoService;

    @Autowired
    FormFieldSubsystemService formFieldSubsystemService;

    @Autowired
    private CertificateService certificateService;


    @Autowired
    private CertificateOrderService certificateOrderService;

    @Autowired
    private CertificateIndexService certificateIndexService;

    @Autowired
    private BlacklistService blacklistService;

    @Autowired
    ServiceProviderFeign serviceProviderFeign;

    @Autowired
    private ExhibitionManageFeign exhibitionManageFeign;

    @Value("${com.eastfair.projectId}")
    private Long projectId;


    @Autowired
    private UserAccountServiceFeign userAccountServiceFeign;

    @Override
    public void handlerResult(IPage<CertificateUser> page) {
        // 想让返回值实现自动回显，请将此行代码打开
        // echoService.action(page);
    }

    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list) {
        List<CertificateUser> certificateUserList = list.stream().map((map) -> {
            CertificateUser certificateUser = CertificateUser.builder().build();
            //TODO 请在这里完成转换
            return certificateUser;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(certificateUserList));
    }


    /**
     * 处理参数
     *
     * @param params 分页参数
     */
    @Override
    public void handlerQueryParams(PageParams<CertificateUserPageQuery> params) {
        CertificateUserPageQuery pageQuery = params.getModel();
        //分页处理
        if (ContextUtil.getProjectId() != null) {
            pageQuery.setProjectId(ContextUtil.getProjectId());
        }

        //加密处理
//        if(StringUtils.isNotBlank(pageQuery.getCardNumber())){
//            pageQuery.setCardNumber(TypeHandlerUtil.crypt(pageQuery.getCardNumber()));
//        }
//        if(StringUtils.isNotBlank(pageQuery.getContactInformation())){
//            pageQuery.setContactInformation(TypeHandlerUtil.crypt(pageQuery.getContactInformation()));
//        }
    }


    /**
     * 答题动态表单
     *
     * @param certificateUserDTO
     * @return 是否成功
     */
    @ApiOperation(value = "答题动态表单", notes = "答题动态表单")
    @PostMapping("/executeFormAnswer")
    @SysLog("答题动态表单")
//    @BaseControllerInfo()
    @BaseControllerInfo(voGroup = CertificateUserGroup.submitForm.class)
    public R<List<FormFieldSubsystemVO>> executeFormAnswer(@RequestBody CertificateUserDTO certificateUserDTO) {
        Certificate certificate = certificateService.getByIdCache(certificateUserDTO.getCertificateId());
        if (certificate == null) {
            throw BizException.wrap(CertificateExceptionCode.CERTIFICATE_NULL);
        }
        FormFieldSubsystemDTO formFieldSubsystemDTO = new FormFieldSubsystemDTO();
        //查询动态表单
        formFieldSubsystemDTO.setRelatedId(certificateUserDTO.getCertificateId());
        formFieldSubsystemDTO.setIsEnabled(BusinessConstant.YES);
        R<List<FormFieldSubsystemVO>> r = formFieldSubsystemService.listDynamicFrom(formFieldSubsystemDTO);
        if (!r.getIsSuccess()) {
            return r;
        }
        certificateUserDTO.setExhibitionId(certificate.getExhibitionId());
        certificateUserDTO.setExhibitorId(certificate.getExhibitionId());
        r = ConvertByFormField.assembleObjectToField(r.getData(), certificateUserDTO);
        if (r.getIsSuccess()) {
            return r;
        }
        return R.success(null);
    }


    /**
     * 提交动态表单
     *
     * @param formFieldSubsystemVOList
     * @return 是否成功
     */
    @ApiOperation(value = "提交动态表单", notes = "提交动态表单")
    @PostMapping("/submitForm")
    @BaseControllerInfo()
    @SysLog("提交动态表单")
    public R<CertificateUser> submitForm(@RequestBody List<FormFieldSubsystemVO> formFieldSubsystemVOList) {
        //校验动态表单
//        R r = formFieldServiceFeign.verifyForm(formFieldSubsystemVOList);
//        if (!r.getIsSuccess()) {
//            return r;
//        }
        R<CertificateUserDTO> certificateUserDTOR = ConvertByFormField.assembleFieldToObject(formFieldSubsystemVOList, CertificateUserDTO.class);
        if (certificateUserDTOR.getIsSuccess()) {
            CertificateUserDTO certificateUserDTO = certificateUserDTOR.getData();

            if (ContextUtil.getTeamId() != null) {
                //说明是团队服务商
                if (StringUtils.isBlank(certificateUserDTO.getPrincipalType())) {
                    ServiceProviderDTO query = new ServiceProviderDTO();
                    query.setIds(Arrays.asList(ContextUtil.getTeamId()));
                    R<List<ServiceProviderVO>> serviceProviderListR = serviceProviderFeign.queryServiceProvider(query);
                    if (serviceProviderListR.getIsSuccess() && serviceProviderListR.getData() != null && !serviceProviderListR.getData().isEmpty()) {
                        for (ServiceProviderVO serviceProviderVO : serviceProviderListR.getData()) {
                            certificateUserDTO.setPrincipalType(serviceProviderVO.getServiceProviderType());
                        }
                    }
                }
                if (certificateUserDTO.getCompanyId() == null) {
                    certificateUserDTO.setCompanyId(ContextUtil.getTeamId());
                }
            }
            //是否是黑名单
            Certificate certificate = certificateService.getByIdCache(certificateUserDTO.getCertificateId());
            Boolean pan = blacklistService.isInBlackList(certificateUserDTO.getCardNumber(),
                    certificate.getExhibitionId(),
                    certificateUserDTO.getContactInformation(),
                    certificateUserDTO.getCompanyId());
            if (pan) {
                return R.fail("该用户是黑名单");
            }
            //校验车证指标数
            if (certificateUserDTO.getId() == null && StringUtils.isNotBlank(certificateUserDTO.getSpaceCode())) {
//                Certificate certificate = certificateService.getByIdCache(certificateUserDTO.getCertificateId());
                //校验证件指标数
                if (certificate.getIndexNumber().intValue() - (certificate.getUseIndexNumber() == null ? 0 : certificate.getUseIndexNumber().intValue()) < 1) {
                    throw BizException.wrap(CertificateExceptionCode.INDEX_NO);
                } else {
                    certificate.setUseIndexNumber(certificate.getUseIndexNumber() == null ? 1 : certificate.getUseIndexNumber() + 1);
                    certificateService.updateById(certificate);
                }

                CertificateCertificateTypeEnum certificateCertificateTypeEnum = certificate.getCertificateType();
                if (CertificateCertificateTypeEnum.CAR == certificateCertificateTypeEnum || CertificateCertificateTypeEnum.PEOPLE == certificateCertificateTypeEnum) {
                    //车证和人证有指标数
                    certificateIndexService.verifyIndex(certificateUserDTO.getCertificateId(), certificateUserDTO.getSpaceCode(), certificateUserDTO.getComeInTime());
                }
            }
            CertificateUser certificateUser = baseService.submitForm(certificateUserDTO);
            return R.success(certificateUser);
        }
        return R.fail("提交失败");
    }

    /**
     * 查询证件动态表单答题详情
     *
     * @param id
     * @return 是否成功
     */
    @ApiOperation(value = "查询证件动态表单答题详情", notes = "查询证件动态表单答题详情")
    @GetMapping("/dynamicFormDetail")
    @TenantAuth()
    @SysLog("查询证件动态表单答题详情")
    public R<List<FormFieldSubsystemVO>> dynamicFormDetail(Long id) {
        //校验动态表单
        CertificateUser certificateUser = baseService.getByIdCache(id);
        CertificateUserVO certificateUserVO = baseService.doToVo(certificateUser);

        //查询动态表单
        FormFieldSubsystemDTO formFieldSubsystemDTO = new FormFieldSubsystemDTO();
        formFieldSubsystemDTO.setRelatedId(certificateUserVO.getCertificateId());
        formFieldSubsystemDTO.setIsEnabled(BusinessConstant.YES);
        R<List<FormFieldSubsystemVO>> r = formFieldSubsystemService.listDynamicFrom(formFieldSubsystemDTO);
        if (!r.getIsSuccess()) {
            return r;
        }
        r = ConvertByFormField.assembleObjectToField(r.getData(), certificateUserVO);
        return r;
    }

    /**
     * 分页查询审核表单
     *
     * @param params
     * @return 是否成功
     */
    @SysLog("分页查询审核表单")
    @ApiOperation(value = "分页查询审核表单", notes = "分页查询审核表单")
    @PostMapping("/pageFirstAuthForm")
    @BaseControllerInfo(voGroup = CertificateUserGroup.pageFirstAuthForm.class)
    @TenantAuth()
    public R<IPage<CertificateUserVO>> pageFirstAuthForm(@RequestBody PageParams<CertificateUserDTO> params) {
        CertificateUserDTO certificateUserDTO = params.getModel();
        if (certificateUserDTO != null && certificateUserDTO.getIsQueryApply() != null && certificateUserDTO.getIsQueryApply() == BusinessConstant.YES) {
            ContextUtil.setIsSystemOlationIgnore(false);
        }
        if (certificateUserDTO != null && StringUtils.isNotBlank(certificateUserDTO.getFuzzySearch())) {
            //查询公司信息
            ServiceProviderDTO serviceProviderDTO = new ServiceProviderDTO();
            serviceProviderDTO.setCompanyName(certificateUserDTO.getFuzzySearch());
            serviceProviderDTO.setExhibitionManageId(certificateUserDTO.getExhibitionId());
            R<List<Long>> listR = serviceProviderFeign.queryServiceProviderIds(serviceProviderDTO);
            if (listR.getIsSuccess() && CollectionUtil.isNotEmpty(listR.getData())) {
                certificateUserDTO.setCompanyIds(listR.getData());
            }
        }

        IPage<CertificateUserVO> certificateUserVOIPage = baseService.pageFirstAuthForm(params);
        List<CertificateUserVO> certificateUserVOList = certificateUserVOIPage.getRecords();
        //订单信息
        if (certificateUserVOList != null && !certificateUserVOList.isEmpty()) {
            List<Long> orderIds = certificateUserVOList.stream().filter(s -> s.getOrderId() != null).map(CertificateUserVO::getOrderId).collect(Collectors.toList());
            if (orderIds != null && !orderIds.isEmpty()) {
                List<CertificateOrderVO> certificateOrderVOList = certificateOrderService.doToVos(certificateOrderService.list(null, orderIds));
                if (certificateOrderVOList != null && !certificateOrderVOList.isEmpty()) {
                    for (CertificateUserVO certificateUserVO : certificateUserVOList) {
                        for (CertificateOrderVO certificateOrderVO : certificateOrderVOList) {
                            if (certificateOrderVO.getId().equals(certificateUserVO.getOrderId())) {
                                certificateUserVO.setCertificateOrderVO(certificateOrderVO);
                            }

                        }
                    }
                }
            }
        }
        certificateUserVOIPage.setRecords(certificateUserVOList);
        return R.success(certificateUserVOIPage);
    }


    /**
     * 初次审核表单
     *
     * @param certificateUserDTO
     * @return
     */
    @ApiOperation(value = "初次审核表单", notes = "初次审核表单")
    @PostMapping("/firstAuthForm")
    @BaseControllerInfo()
    @TenantAuth()
    @SysLog("初次审核表单")
    public R firstAuthForm(@RequestBody CertificateUserDTO certificateUserDTO) {
        return R.success(baseService.firstAuthForm(certificateUserDTO));
    }


    /**
     * 二次审核表单
     *
     * @param certificateUserDTO
     * @return
     */
    @ApiOperation(value = "二次审核表单", notes = "二次审核表单")
    @PostMapping("/secondAuthForm")
    @BaseControllerInfo()
    @TenantAuth()
    @SysLog("二次审核表单")
    public R secondAuthForm(@RequestBody CertificateUserDTO certificateUserDTO) {
        return R.success(baseService.secondAuthForm(certificateUserDTO));
    }

    /**
     * 注销
     *
     * @param certificateUserDTO 保存参数
     * @return 实体
     */
    @ApiOperation(value = "注销")
    @PostMapping("/clearCertificate")
    @TenantAuth()
    @SysLog("注销")
    public R clearCertificate(@RequestBody CertificateUserDTO certificateUserDTO) {
        return R.success(baseService.clearCertificate(certificateUserDTO));
    }

    /**
     * 挂失
     *
     * @param certificateUserDTO 保存参数
     * @return 实体
     */
    @ApiOperation(value = "挂失")
    @PostMapping("/lessCertificate")
    @TenantAuth()
    @SysLog("挂失")
    public R lessCertificate(@RequestBody CertificateUserDTO certificateUserDTO) {
        return R.success(baseService.lessCertificate(certificateUserDTO));
    }


    /**
     * 加入黑名单
     *
     * @param blacklistDTO 保存参数
     * @return 实体
     */
    @ApiOperation(value = "加入黑名单")
    @PostMapping("/addBack")
    @SysLog("加入黑名单")
    public R addBack(@RequestBody BlacklistDTO blacklistDTO) {
        List<CertificateUser> certificateUserList = baseService.list(null, blacklistDTO.getCertificateUserIdList());
        certificateUserList = certificateUserList.stream().filter(s -> BusinessConstant.NO == s.getIsBlack() && !(CertificateUserFirstAuthStatusEnum.CHECK_SUCC.eq(s.getFirstAuthStatus())
                && CertificateUserSecondAuthStatusEnum.CHECK_SUCC.eq(s.getSecondAuthStatus()))).collect(Collectors.toList());
        if (CollectionUtil.isEmpty(certificateUserList)) {
            //不需要初次审核
            throw NoBackBizException.wrap(CertificateExceptionCode.BLACK_NULL);
        }
        for (CertificateUser certificateUser : certificateUserList) {
            certificateUser.setIsBlack(BusinessConstant.YES);
            baseService.updateById(certificateUser);
        }
        //异步
//        ExecutorService executorService = Executors.newCachedThreadPool();
//        executorService.submit(() -> {
        List<CertificateUserVO> list = baseService.doToVos(certificateUserList);
        //展会信息
        List<Long> exhibitionIds = list.stream().map(CertificateUserVO::getExhibitionId).collect(Collectors.toList());
        ExhibitionManageQuery exhibitionManageQuery = new ExhibitionManageQuery();
        exhibitionManageQuery.setIds(exhibitionIds);
        R<List<ExhibitionManageVO>> listR = exhibitionManageFeign.queryAllExhibitionManage(exhibitionManageQuery);
        if (listR.getIsSuccess() && listR.getData() != null && !listR.getData().isEmpty()) {
            for (ExhibitionManageVO exhibitionManageVO : listR.getData()) {
                for (CertificateUserVO certificateUserVO : list) {
                    if (exhibitionManageVO.getId().equals(certificateUserVO.getExhibitionId())) {
                        certificateUserVO.setExhibitionManageVO(exhibitionManageVO);
                    }
                }
            }
        }
//        baseService.assembleBusinssData(list);
        for (CertificateUserVO certificateUserVO : list) {
//                if (BusinessConstant.YES == certificateUserVO.getIsBlack()) {
//                    continue;
//                }
            Blacklist blacklist = new Blacklist();
            blacklist.setExhibitionId(certificateUserVO.getExhibitionId());
            blacklist.setExhibitionName(certificateUserVO.getExhibitionManageVO().getExhibitionName());
            blacklist.setUserName(certificateUserVO.getFullName());
            blacklist.setCardNumber(certificateUserVO.getCardNumber());
            blacklist.setPhoneNumber(certificateUserVO.getContactInformation());
            blacklist.setCompanyName(certificateUserVO.getCompanyName());
            blacklist.setCompanyId(certificateUserVO.getCompanyId());
            blacklist.setRemark(blacklistDTO.getRemark());
            blacklist.setKind(BlacklistKindEnum.EXHIBITION);
            //查询是否存在
            BlacklistDTO blacklistDTO1 = new BlacklistDTO();
            BeanUtils.copyProperties(blacklist, blacklistDTO1);
            blacklistDTO1.setRemark(null);
            List<Blacklist> blacklists = blacklistService.list(blacklistDTO1, null);
            if (CollectionUtil.isEmpty(blacklists)) {
                blacklistService.addBlack(blacklist);
            }
            if (blacklistDTO.getIsSycnExhition()) {
                //加入到展会黑名单
                blacklist = new Blacklist();
                blacklist.setExhibitionId(certificateUserVO.getExhibitionId());
                blacklist.setExhibitionName(certificateUserVO.getExhibitionManageVO().getExhibitionName());
                blacklist.setUserName(certificateUserVO.getFullName());
                blacklist.setCardNumber(certificateUserVO.getCardNumber());
                blacklist.setPhoneNumber(certificateUserVO.getContactInformation());
                blacklist.setCompanyName(certificateUserVO.getCompanyName());
                blacklist.setCompanyId(certificateUserVO.getCompanyId());
                blacklist.setRemark(blacklistDTO.getRemark());
                blacklist.setKind(BlacklistKindEnum.VENUE);
                //查询是否存在
                blacklistDTO1 = new BlacklistDTO();
                BeanUtils.copyProperties(blacklist, blacklistDTO1);
                blacklistDTO1.setRemark(null);
                blacklists = blacklistService.list(blacklistDTO1, null);
                if (CollectionUtil.isEmpty(blacklists)) {
                    blacklistService.addBlack(blacklist);
                }

            }
        }
//        });
        return R.success();
    }


    /**
     * 同步展览数据
     *
     * @param certificateUserDTO 保存参数
     * @return 实体
     */
    @ApiOperation(value = "同步展览数据")
    @PostMapping("/sycnECertificateUser")
    @SysLog("同步展览数据")
    public R sycnECertificateUser(@RequestBody CertificateUserDTO certificateUserDTO) {
        ContextUtil.setProjectId(projectId);
        List<CertificateUserDTO> certificateUserList = certificateUserDTO.getCertificateUserList();
        if (CollectionUtil.isNotEmpty(certificateUserList)) {
            for (CertificateUserDTO certificateUserDTO1 : certificateUserList) {
                CertificateUser certificateUser = baseService.getByIdCache(certificateUserDTO1.getEUuid());
                if (certificateUser != null) {
                    certificateUserDTO1.setId(certificateUser.getId());
                    BeanUtils.copyProperties(certificateUserDTO1, certificateUser);
                    certificateUser.setEDataJson(JSONObject.toJSONString(certificateUserDTO1));
                    baseService.updateById(certificateUser);
                } else {
                    certificateUser = new CertificateUser();
                    BeanUtils.copyProperties(certificateUserDTO1, certificateUser);
                    certificateUser.setCertificateStatus(CertificateUserCertificateStatusEnum.NO_PRINT);
                    certificateUser.setFirstAuthStatus(CertificateUserFirstAuthStatusEnum.CHECK_SUCC);
                    certificateUser.setSecondAuthStatus(CertificateUserSecondAuthStatusEnum.CHECK_SUCC);
                    certificateUser.setIsCancel(BusinessConstant.NO);
                    certificateUser.setIsLoss(BusinessConstant.NO);
                    certificateUser.setIsDraw(BusinessConstant.NO);
                    certificateUser.setIsBlack(BusinessConstant.NO);
                    certificateUser.setIsPay(BusinessConstant.NO);
                    certificateUser.setIsSycn(BusinessConstant.NO);
                    certificateUser.setResourceType(CertificateUserResourceTypeEnum.ONLINE);
                    certificateUser.setDataResource(CertificateUserDataResourceEnum.E);
                    certificateUser.setEDataJson(JSONObject.toJSONString(certificateUserDTO1));
                    baseService.save(certificateUser);
                }
            }
        }
        return R.success();
    }


    /**
     * 领取
     *
     * @param certificateUserDTO
     * @return
     */
    @PostMapping("/draw")
    @ApiOperation(value = "领取")
    @SysLog("领取")
    public R draw(@RequestBody CertificateUserDTO certificateUserDTO) {
        baseService.draw(certificateUserDTO);
        return R.success();
    }

    /**
     * 退款金额
     *
     * @param id 订单id
     * @return
     */
    @GetMapping("/findVo/{id}")
    @ApiOperation(value = "退款金额")
    @SysLog("查询退款金额")
    public R<CertificateUserVO> queryReturnMoney(@PathVariable Long id) {
        CertificateUser certificateUser = baseService.getByIdCache(id);
        if (certificateUser == null) {
            return R.success(null);
        }
        CertificateUserVO certificateUserVO = baseService.doToVo(certificateUser);
        List<CertificateUserVO> list = new ArrayList<>();
        list.add(certificateUserVO);
        baseService.assembleBusinssData(list);
        log.info("findVo result is {}",JSONObject.toJSONString(list.get(0)));
        return R.success(list.get(0));
    }


    /**
     * 用户是否在黑名单
     *
     * @param certificateUserDTO 用户信息
     * @return
     */
    @PostMapping("/userIsBlack")
    @ApiOperation(value = "用户是否在黑名单")
    @SysLog("用户是否在黑名单")
    public R userIsBlack(@RequestBody CertificateUserDTO certificateUserDTO) {
//        R<UserAccountVo> userAccountVoR = userAccountServiceFeign.findSimpleById(1869275011695251456L);
        //是否是黑名单
        Certificate certificate = certificateService.getByIdCache(certificateUserDTO.getCertificateId());
        Boolean pan = blacklistService.isInBlackList(certificateUserDTO.getCardNumber(),
                certificate.getExhibitionId(),
                certificateUserDTO.getContactInformation(),
                certificateUserDTO.getCompanyId());
        if (pan) {
            return R.fail("该用户是黑名单");
        }
        return R.success();
    }


    /**
     * 用户是否在黑名单
     *
     * @param certificateUserDTO 用户信息
     * @return
     */
    @PostMapping("/list")
    @ApiOperation(value = "用户是否在黑名单")
    @SysLog("用户是否在黑名单")
    public R list(@RequestBody CertificateUserDTO certificateUserDTO) {
        return R.success(baseService.list(certificateUserDTO, null));
    }

}
